/**
 * 
 */
package net.da.tools;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PackageStructure {

	private Map<String, ClassDescriptor> structure = new HashMap<String, ClassDescriptor>();

	public void addClass(ClassDescriptor classDescriptor) {
		structure.put(classDescriptor.getFullName(), classDescriptor);
	}

	public ClassDescriptor findClass(String fullName) {
		return structure.get(fullName);
	}

	public List<ClassDescriptor> getAllClasses() {
		return Collections.unmodifiableList(new ArrayList<ClassDescriptor>(
				structure.values()));

	}

	public boolean containsClass(String fullName) {
		return structure.containsKey(fullName);
	}

	public List<ClassDescriptor> getClasses(String packageName) {

		List<ClassDescriptor> all = getAllClasses();
		List<ClassDescriptor> required = new ArrayList<ClassDescriptor>();
		for (ClassDescriptor cd : all) {
			if (cd.getPackageName().startsWith(packageName)) {
				required.add(cd);
			}			
		}		
		return Collections.unmodifiableList(required);
	}

}
